package com.xhwy.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Value("${file.staticPatternPath}")
    private String staticPatternPath;
    @Value("${file.uploadFolder}")
    private String uploadFolder;


    // springboot 中 springMVC 让程序开发者去配置文件上传的额外的静态资源服务的配置
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //访问路径
//        registry.addResourceHandler("/upload/**")
//                //上传资源的路径
//                .addResourceLocations("file:D://upload//");
        registry.addResourceHandler("/" + staticPatternPath + "/**")
                .addResourceLocations("file:" + uploadFolder);

    }
}
